Sample Test 2

Sample Test 2

Programs that do not compile (contain errors) will not be graded.

Cheating will be penalized, all works will be checked for plagiarism. During solving of the test use only code of your authorship.

You have 90 minutes to solve the test, the assignment with close at the appointed deadline. Only a solution uploaded to the designated eKursy assignment will be checked, no other means of providing the code will be accepted.

Task 0

Avoid copying the data when not required (use reference or const reference instead, especially when passing containers). Do not use global variables.

Text file students.txt contains information about students and points scored during 10 different tests. File contains name, surname and 10 integer values for each entry. The file has a following format:

name:surname:p1,p2,p3,p4,p5,p6,p7,p8,p9,p10

FILE DOWNLOAD: students.txt

Task 1

Read the information about students and their points. Store the information using a std::vector of structures - design a structure to store all information.

Task 2

Write a function called final_score which will return a final score for a student, being a sum of all partial results from all the tests.

Example call:

std::vector<int> partial_points {10, 8, 2, 10, 5, 8, 9, 2, 1, 10};
int sum_points = final_score(partial_points); // 65 points

Task 3

Second text file marks.txt contains information about mark scale of Information Engineering course. Each lines contains range of total points and assigned grade. File has the following format:

lower_limit-upper_limit;grade

FILE DOWNLOAD: marks.txt

Read the information about grading scale into collection of structures called grade_scale.

Task 4

Write a function called grade_based_on_score which will return a final grade based on provided sum of points and grading scale from marks.txt file.

Example call:

double final_grade = grade_based_on_score (85, grade_scale); // grade: 4.5

Task 5

Using final_score and grade_based_on_score functions calculate a grade for each student from students.txt file, store calculated grades for next tasks.

Task 6

Write the list of students into a new file students_grades.txt in the following format:

name;surname;grade

Bonus

Using std::sort algorithm sort students based on achieved final grade – in descending order. Update Task 6 to store sorted list of students.


Authors: Jakub Tomczyński, Tomasz Mańkowski